<!DOCTYPE HTML>
<html xmlns:th="http://www.thymeleaf.org">
<head>
    <title th:text="${question.title}"></title>
    <meta http-equiv="Content-Type" content="text/html; charset=UTF-8"/>
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <link rel="stylesheet" href="/nodeModules/bootstrap/dist/css/bootstrap.min.css">
    <link rel="stylesheet" href="/nodeModules/bootstrap/dist/css/bootstrap-theme.min.css">
    <link rel="stylesheet" href="/nodeModules/css/community.css">
    <link rel="stylesheet" href="/nodeModules/editor.md/css/editormd.preview.min.css">
    <script src="/nodeModules/jquery/dist/jquery.min.js"></script>
    <script src="/nodeModules/bootstrap/dist/js/bootstrap.min.js"></script>
    <script src="/nodeModules/moment/moment.js"></script>
    <script src="/nodeModules/js/community.js"></script>
    <script src="/nodeModules/editor.md/editormd.min.js"></script>
    <script src="/nodeModules/editor.md/lib/marked.min.js"></script>
    <script src="/nodeModules/editor.md/lib/prettify.min.js"></script>
</head>
<body>
<!--顶部-->
<div th:insert="~{navigation :: nav}"></div>
<!--内容-->
<div class="container main profile">
    <div class="row">
        <!--左边主要内容-->
        <div class="col-lg-9 col-md-12 col-sm-12 col-xs-12" style="border-right:1px solid #DDDDDD;">
            <!--标题和内容-->
            <div class="col-lg-12 col-md-12 col-sm-12 col-xs-12">
                <h4 class="question-title"><span th:text="${question.title}"></span></h4>
                <span class="text-desc">
                <span th:text="${question.user.getName()}"></span>&nbsp;&nbsp;&nbsp;
                <span th:text="${#dates.format(question.gmtCreate,'yyyy-MM-dd HH:mm')}"></span>
                阅读 <span th:text="${question.viewCount}"></span>
        </span>
                <hr class="col-lg-12 col-md-12 col-sm-12 col-xs-12">
                <!--内容-->

                <div class="col-lg-12 col-md-12 col-sm-12 col-xs-12" id="question-view">
                    <textarea style="display: none;" th:text="${question.description}"></textarea>
                </div>
                <script type="text/javascript">
                    $(function () {
                        editormd.markdownToHTML("question-view", {});
                    })
                </script>

                <!--标签-->
                <hr class="col-lg-12 col-md-12 col-sm-12 col-xs-12">
                <div class="col-lg-12 col-md-12 col-sm-12 col-xs-12">
                    <span class="label label-info  question-tag" th:each="tag:${question.tag.split(',')}">
                        <span class="glyphicon glyphicon-tags"></span>
                        <span class="label label-info" th:text="${tag}"></span>
                    </span>
                </div>
                <!--编辑-->
                <hr class="col-lg-12 col-md-12 col-sm-12 col-xs-12">
                <div class="col-lg-12 col-md-12 col-sm-12 col-xs-12">
                    <a th:href="@{'/publish/'+${question.id}}" class="community-menu"
                       th:if="${session.user !=null && session.user.id == question.creator}">
                        <span class="glyphicon glyphicon-pencil" aria-hidden="true">编辑</span>
                    </a>
                    &nbsp;&nbsp;&nbsp;
                    <a href="#question-collapse" class="community-menu" data-toggle="collapse" aria-expanded="false"
                       aria-controls="question-collapse">
                        <span class="glyphicon glyphicon-comment"></span> <span
                            th:text="${question.commentCount}"></span> 条回复
                    </a>
                </div>
                <hr class="col-lg-12 col-md-12 col-sm-12 col-xs-12">
            </div>

            <!--回复的内容展示-->
            <div class="col-lg-12 col-md-12 col-sm-12 col-xs-12 collapse well question-comments" id="question-collapse">
                <div class="col-lg-12 col-md-12 col-sm-12 col-xs-12 comments" th:each="comment : ${comments}">
                    <div class="media">
                        <div class="media-left">
                            <a href="#">
                                <img th:src="${comment.user.avatarUrl}"
                                     class="media-object img-rounded">
                            </a>
                        </div>
                        <div class="media-body" th:id="${'comment-body-'+comment.id}">
                            <h5 class="media-heading">
                                <span th:text="${comment.user.name}"></span>
                            </h5>
                            <div th:text="${comment.content}"></div>
                            <div class="menu">
                                <span class="glyphicon glyphicon-thumbs-up icon"></span>
                                <span th:data-id="${comment.id}"
                                      onclick="collapseComments(this)" class="comment-icon">
                                    <span class="glyphicon glyphicon-comment"></span> <span
                                        th:text="${comment.commentCount}"></span> 条回复
                                </span>
                                <span class="pull-right"
                                      th:text="${#dates.format(comment.gmtCreate,'yyyy-MM-dd HH:mm')}"></span>
                            </div>
                            <!--二级评论-->
                            <div class="col-lg-12 col-md-12 col-sm-12 col-xs-12 collapse sub-comments"
                                 th:id="${'comment-'+comment.id}">
                                <div class="col-lg-12 col-md-12 col-sm-12 col-xs-12">
                                    <input type="text" class="form-control" placeholder="写下你的评论...."
                                           th:id="${'input-'+comment.id}">
                                    <button type="button" class="btn btn-success pull-right" onclick="comment(this)"
                                            th:data-id="${comment.id}">评论
                                    </button>
                                </div>
                            </div>
                        </div>
                    </div>
                </div>
            </div>
            <!--评论输入框-->
            <div class="col-lg-12 col-md-12 col-sm-12 col-xs-12">
                <h4>
                    提交回复
                </h4>
                <hr class="col-lg-12 col-md-12 col-sm-12 col-xs-12 comment-sp">
                <div class="col-lg-12 col-md-12 col-sm-12 col-xs-12" id="comment_section">
                    <div class="media">
                        <div class="media-left">
                            <a href="#">
                                <img th:src="${session.user !=null?session.user.avatarUrl:'/images/default-avatar.png'}"
                                     class="media-object img-rounded">
                            </a>
                        </div>
                        <div class="media-body media-body-input">
                            <h5 class="media-heading">
                                <span th:text="${session.user !=null?session.user.name:'匿名用户'}"></span>
                            </h5>
                        </div>
                    </div>
                    <input type="hidden" id="question_id" th:value="${question.id}">
                    <textarea class="form-control comment" rows="6" id="comment_content"
                              placeholder="请写下您的评论..."></textarea>
                    <button type="button" class="btn-comment btn btn-info" onclick="post()">发布</button>
                </div>
            </div>
        </div>
        <!--右边信息块 发布人信息-->
        <div class="col-lg-3 col-md-3 col-sm-12 col-xs-12 question-leftPlace">
            <div class="col-lg-12 col-md-12 hidden-xs hidden-sm question-sender">
                <h4>发起人</h4>
                <div class="media">
                    <div class="media-left">
                        <a href="#">
                            <img th:src="${question.user.avatarUrl}"
                                 class="media-object img-rounded">
                        </a>
                    </div>
                    <div class="media-body">
                        <h5 class="media-heading">
                            <span th:text="${question.user.name}" style="color: #155faa;"></span>
                        </h5>
                        <span th:text="${question.user.bio}" style="color: #999"></span>
                    </div>
                </div>
            </div>
            <!--微信号-->
            <div>
                <!--扫码-->
                <div class="col-lg-12 col-md-12 col-sm-12 col-xs-12 media index-aside-code">
                    <div class="media-left text-left">
                        <img src="/images/wechat.png" class="media-object question-code img-thumbnail">
                    </div>
                    <a class="media-body text-center" id="index-code" data-toggle="popover" data-placement="bottom">
                        <h4 class="media-heading">扫码知猿手机网页 ></h4>
                        <div>随时随地发现和解决问题</div>
                    </a>
                </div>
            </div>
            <!--相关问题-->
            <div class="col-lg-12 col-md-12 col-sm-12 col-xs-12">
                <h4 style="font-size: 16px;font-weight: normal">相关问题</h4>
                <ul class="question-ralated">
                    <li th:each="related:${relatedQuestions}">
                        <a th:href="@{'/question/'+${related.id}}" th:text="${related.title}"></a>
<!--                        <span class="question-correlation"><span-->
<!--                                th:text="${related.getCommentCount()}"></span> 个回答</span>-->
                    </li>
                </ul>
            </div>
            <hr  class="col-lg-12 col-md-12 col-sm-12 col-xs-12">
            <!--问题状态-->
            <div class="col-lg-12 col-md-12 col-sm-12 col-xs-12 question-state">
                <h4 style="font-size: 16px;font-weight: normal">问题状态</h4>
                <ul>
                    <li >
                          最新修改:<span th:text="${#dates.format(question.gmtModified,'yyyy-MM-dd HH:mm')}"></span>
                    </li>
                    <li >
                        浏览:<span th:text="${question.viewCount}"></span>
                    </li>
                </ul>
            </div>
        </div>
    </div>
</div>
<!--底部-->
<div th:insert="~{footer :: foot}"></div>
</body>

</html>